<?php

/**
 * Netdev form base class.
 *
 * @method Netdev getObject() Returns the current form's model object
 *
 * @package    seth
 * @subpackage form
 * @author     Fuz
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseNetdevForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'           => new sfWidgetFormInputHidden(),
      'name'         => new sfWidgetFormInputText(),
      'type'         => new sfWidgetFormInputText(),
      'plant'        => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Plant'), 'add_empty' => false)),
      'system'       => new sfWidgetFormInputText(),
      'network'      => new sfWidgetFormInputText(),
      'ip1'          => new sfWidgetFormInputText(),
      'url'          => new sfWidgetFormInputText(),
      'user1'        => new sfWidgetFormInputText(),
      'pass1'        => new sfWidgetFormInputText(),
      'pingable'     => new sfWidgetFormInputText(),
      'ip2'          => new sfWidgetFormInputText(),
      'ip3'          => new sfWidgetFormInputText(),
      'subnet'       => new sfWidgetFormInputText(),
      'gateway'      => new sfWidgetFormInputText(),
      'user2'        => new sfWidgetFormInputText(),
      'pass2'        => new sfWidgetFormInputText(),
      'note'         => new sfWidgetFormInputText(),
      'subplant'     => new sfWidgetFormInputText(),
      'manufacturer' => new sfWidgetFormInputText(),
      'model'        => new sfWidgetFormInputText(),
      'protocols'    => new sfWidgetFormInputText(),
    ));

    $this->setValidators(array(
      'id'           => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'name'         => new sfValidatorString(array('max_length' => 45)),
      'type'         => new sfValidatorString(array('max_length' => 45)),
      'plant'        => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Plant'))),
      'system'       => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'network'      => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'ip1'          => new sfValidatorInteger(array('required' => false)),
      'url'          => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'user1'        => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'pass1'        => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'pingable'     => new sfValidatorInteger(),
      'ip2'          => new sfValidatorInteger(array('required' => false)),
      'ip3'          => new sfValidatorInteger(array('required' => false)),
      'subnet'       => new sfValidatorInteger(array('required' => false)),
      'gateway'      => new sfValidatorInteger(array('required' => false)),
      'user2'        => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'pass2'        => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'note'         => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'subplant'     => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'manufacturer' => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'model'        => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'protocols'    => new sfValidatorString(array('max_length' => 160, 'required' => false)),
    ));

    $this->widgetSchema->setNameFormat('netdev[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Netdev';
  }

}
